# See LICENSE file for copyright and license details.

include config.mk

SRC = w4.c
OBJ = $(SRC:.c=.o)

LIB = libw4.a
INC = w4.h

all: $(LIB)

$(LIB): $(OBJ)
	@$(AR) -rcs $@ $(OBJ)

.c.o:
	@$(CC) $(CFLAGS) -c $<

w4.3.gz: w4.3
	@gzip -k w4.3

install: $(LIB) $(INC) w4.3.gz
	@echo @ install libw4 to $(PREFIX)
	@mkdir -p $(PREFIX)/lib
	@cp $(LIB) $(PREFIX)/lib/$(LIB)
	@echo @ install w4.h to $(PREFIX)
	@mkdir -p $(PREFIX)/include/
	@cp $(INC) $(PREFIX)/include/
	@echo @ install w4.3 to $(PREFIX)
	@mkdir -p $(PREFIX)/share/man/man3/
	@install -m 644 w4.3.gz $(PREFIX)/share/man/man3/

uninstall:
	@echo @ uninstall w4 from $(PREFIX)
	@rm -f $(PREFIX)/lib/$(LIB)
	@rm -f $(PREFIX)/include/$(INC)
	@rm -f $(PREFIX)/share/man/man3/w4.3.gz

clean:
	@rm -f $(LIB) $(OBJ) w4.3.gz
